#include <bits/stdc++.h>
using namespace std;
int h[500001];
int help[500001];//
int win;
int ans;
int main() {
  int n = 0;
  int gaodu;
  while (cin >> gaodu) {
    n = n + 1;
    h[n] = gaodu;
  }
  for (int i = 1; i <= n; i++) {
    help[i] = 1;
    for (int j = 1; j <= i - 1; j++) {
      if (h[j] >= h[i] && help[j] + 1 > help[i]) {
        help[i] = help[j] + 1;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    win = max(win, help[i]);
  }
  cout << win << endl;

  for (int i = 1; i <= n; i++) {
    help[i] = 1;
    for (int j = 1; j <= i - 1; j++) {
      if (h[j] < h[i] && help[j] + 1 > help[i]) {
        help[i] = help[j] + 1;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    ans = max(ans, help[i]);
  }
  cout << ans;
  return 0;
}